﻿var SCA = SCA || {};
SCA.UI = SCA.UI || {};
SCA.UI.SiteSettings = SCA.UI.SiteSettings || {};

SCA.UI.SiteSettings.Table = function () {

    this.AddRow = function (index) {
        var lastTr = jQuery('#TableSiteSettings tr:last');
        var rowHtml = '<tr id="TRTableSiteSettings' + index + '">\
                            <td>\
                                <input type="button" value="Edit" class="site-setting-edit-button" onclick="OpenSiteSettingsDialog(\'' + index + '\')"/>\
                                <input type="button" value="Delete" class="sbs-button" onclick="mainUI.siteSettingsTable.DeleteRow(\'' + index + '\')"/>\
                            </td>\
                            <td id="TDTableSiteSettings'+ index + '_1">\
                                '+ SCA.AppConfiguration.SiteSettings[index].SiteSettingType +
                            '</td>\
                            <td id="TDTableSiteSettings' + index + '_2">\
                                '+ SCA.AppConfiguration.SiteSettings[index].Url +
                            '</td>\
                      </tr>';
        lastTr.after(rowHtml);
    }

    this.DeleteRow = function(index){
        jQuery("#TRTableSiteSettings" + index).hide();
        SCA.AppConfiguration.SiteSettings[index].IsDeleted = true;
    }

    this.RefreshRow = function (index)
    {
        jQuery("#TDTableSiteSettings" + index + "_1").html(SCA.AppConfiguration.SiteSettings[index].SiteSettingType);
        jQuery("#TDTableSiteSettings" + index + "_2").html(SCA.AppConfiguration.SiteSettings[index].Url);
    }
}
